package com.qq.activity.base;
    
 

import android.app.ExpandableListActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.qq.R;


public class ExpandableBaseActivity extends ExpandableListActivity{
  
	protected Button leftBtn;
	protected ImageView rightBtn;
	protected TextView titleText; 
	protected LinearLayout tabLy;
	protected Button tabLeftBtn;
	protected Button tabRightBtn;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState); 
	} 
	
	protected void initTopBar(String title){ 
		leftBtn = (Button)this.findViewById(R.id.header_btn_left);
		rightBtn = (ImageView)this.findViewById(R.id.header_iv_right);
		titleText = (TextView)this.findViewById(R.id.header_text_title); 
		tabLy = (LinearLayout)this.findViewById(R.id.ly_header_tab);
		tabLeftBtn = (Button)this.findViewById(R.id.btn_header_tab_left); 
		tabRightBtn = (Button)this.findViewById(R.id.btn_header_tab_right); 
		titleText.setText(title);
		tabLy.setVisibility(View.GONE);
		initEvent();
	}
	
	protected void initTopBar(){ 
		leftBtn = (Button)this.findViewById(R.id.header_btn_left);
		rightBtn = (ImageView)this.findViewById(R.id.header_iv_right);
		titleText = (TextView)this.findViewById(R.id.header_text_title); 
		tabLy = (LinearLayout)this.findViewById(R.id.ly_header_tab);
		tabLeftBtn = (Button)this.findViewById(R.id.btn_header_tab_left); 
		tabRightBtn = (Button)this.findViewById(R.id.btn_header_tab_right); 
		tabLy.setVisibility(View.VISIBLE);
		titleText.setVisibility(View.GONE);
		initEvent();
	}
	
	protected void initRightBtn(boolean isVisibility,int bg,int src){ 
		if(isVisibility)
		{
			rightBtn.setVisibility(View.VISIBLE);
		}
		else
		{
			rightBtn.setVisibility(View.GONE);
		}
		if(bg != 0)
		{
		    rightBtn.setBackgroundResource(bg);
		}
		if(src != 0)
		{
			rightBtn.setImageResource(src);
		}
		
	}
	
	protected void initEvent(){ 
		leftBtn.setOnClickListener(onclick);
		rightBtn.setOnClickListener(onclick); 
		tabLeftBtn.setOnClickListener(onclick);
		tabRightBtn.setOnClickListener(onclick); 
	}
	
	private OnClickListener  onclick = new OnClickListener() {
		@Override
		public void onClick(View v) {
			switch(v.getId()){
			case R.id.header_btn_left:
				leftBtnHandle();
				break;
			case R.id.header_iv_right:
				rightBtnHandle();
				break;
			case R.id.btn_header_tab_left:
				tabLeftBtnHandle();
				break;
			case R.id.btn_header_tab_right:
				tabRightBtnHandle();
				break;
			}
		}
	};
	
	protected void leftBtnHandle(){
		finish();
	}
	
	protected void rightBtnHandle(){}
	
	protected void tabRightBtnHandle(){}
	
	protected void tabLeftBtnHandle(){}
}













